//package com.handsome.mailservice;
//
//import org.springframework.amqp.rabbit.core.RabbitTemplate;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.mail.javamail.JavaMailSenderImpl;
//import org.springframework.mail.javamail.MimeMessageHelper;
//import org.springframework.stereotype.Service;
//
//import javax.mail.MessagingException;
//import javax.mail.internet.MimeMessage;
//import java.io.File;
//
///**
// * @Author Handsome
// * @Date 2022/1/27 17:10
// * @Version 1.0
// */
//@SuppressWarnings({"all"})
//@Service
//public class MailRabbitService {
//
//    @Autowired
//    private RabbitTemplate rabbitTemplate;
//    @Autowired
//    JavaMailSenderImpl mailSender;
//
//    public void sendMail() throws Exception {
//
//        String msg = "邮件发送成功！";
//        // 获取绝对路径
//        String root = System.getProperty("user.dir");
//        // 图片位置
//        String pathname = root + "\\mailPicture\\1.jpg";
//        //一个复杂的邮件
//        MimeMessage mimeMessage = mailSender.createMimeMessage();
//        //组装
//        MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true);
//        helper.setSubject("识时务者Handsome");
//        helper.setText("<h1 style = 'color: red;text-align: center;'>" +
//                        "验证码都能错<br>老笨比了啊!" +
//                        "</h1>"
//                , true);
//        //附件
//        helper.addAttachment("美女图片.jpg", new File(pathname));
//        helper.setTo("1327259918@qq.com");
//        // 熊猪QQ：3042992513
//        helper.setFrom("1327259918@qq.com");
//        mailSender.send(mimeMessage);
//
//        String exchangeName = "Mail_Rabbit_FanoutExchange";
//        String routingKey = "";
//        rabbitTemplate.convertAndSend(exchangeName,routingKey,msg);
//
//    }
//}
